/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package extension.phom.handler;

import com.smartfoxserver.v2.entities.User;
import com.smartfoxserver.v2.entities.data.ISFSObject;
import com.smartfoxserver.v2.extensions.BaseClientRequestHandler;
import extension.room.phom.PhomExtension;
import extension.room.phom.PhomGame;
import extension.room.phom.PhomPlayer;
import extension.room.phom.PhomResponse;

/**
 *
 * @author daz
 */
public class ChoosePhomHandler extends BaseClientRequestHandler {

    @Override
    public void handleClientRequest(User user, ISFSObject params) {
        PhomExtension phomExtension = (PhomExtension) getParentExtension();
        PhomGame game = phomExtension.getGame();
        PhomResponse response = phomExtension.getResponse();
        PhomPlayer p = game.getPlayerFight();
        if (p.getListSubPhom() != null) {
            if (p.isShowSubPhom()) {
                response.sendCardPhom(p.getSeatPos(), p.getListSubPhom(), user);
                p.setPhomType(PhomPlayer.SUB_PHOM);
                p.setShowSubPhom(false);
            } else {
                response.sendCardPhom(p.getSeatPos(), p.getListPhom(), user);
                p.setPhomType(PhomPlayer.MAIN_PHOM);
                p.setShowSubPhom(true);
            }
        } else {
            if (p.getIsMoreFightTurn()) {
                p.setPhomType(PhomPlayer.MAIN_PHOM);
                response.sendCardPhom(p.getSeatPos(), p.getListPhomMore(), user);
            } else {
                p.setPhomType(PhomPlayer.MAIN_PHOM);
                response.sendCardPhom(p.getSeatPos(), p.getListPhom(), user);
            }
        }

    }
}
